﻿@model IEnumerable<MvcApplication2.Models.Recipe>

@{
    ViewBag.Title = "Wyszukiwanie przepisów";
}

<h2>Wyszukiwanie przepisów</h2>

    @using (Html.BeginForm("SearchIndex","Recipes",FormMethod.Get))
    {   
         <p>Nazwa:<br />@Html.TextBox("SearchString")</p>
         <p>Kategoria:<br />@Html.DropDownList("category", "Wszystkie")</p>
         <p>Dodał:<br />@Html.TextBox("userSearch")</p>
         <input type="submit" value="Szukaj" />
    }
    <br />
<table>
    <tr>
        <th>
            Zdjęcie
        </th>
        <th>
            Nazwa
        </th>
        <th>
            Kategoria
        </th>
        <th>
            Dodał
        </th>
        <th></th>
    </tr>

@foreach (var item in Model)
{
    <tr>
        <td>
            @if (item.ImagePath != null)
            {
                <img src="../uploads/@Html.DisplayFor(modelItem => item.ImagePath)" width="200"/>
            }
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Title)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Category.Name)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.User.Login)
        </td>
        <td>
            @Html.ActionLink("Zobacz", "Details", new { id = item.RecipeID })
            @if (item.User.Login.Equals(Session["LoggedLogin"]) || true.Equals(Session["LoggedAdmin"]))
            {
                @Html.Raw(" | ")
                @Html.ActionLink("Edytuj", "Edit", new { id = item.RecipeID })
                @Html.Raw(" | ")
                @Html.ActionLink("Usuń", "Delete", new { id = item.RecipeID })
            }
        </td>
    </tr>
}

</table>
